#include <iostream>
#include <string>

#define MAX_DIGITS 8
#define MAX_S 10
#define H_SPACES 3
#define HEIGHT(s) (2*s+H_SPACES)
#define WIDTH(x,s) (x*(s+2)+(x == 0 ? 0 : x-1))

using namespace std;

char digits[HEIGHT(MAX_S)][WIDTH(MAX_DIGITS, MAX_S)];

void print(int n, int s)
{
//   cout<<"print"<<endl;
   for(int i = 0; i < HEIGHT(s); i++)
   {
      for(int j = 0; j < WIDTH(n, s); j++)
      {
         cout<<digits[i][j];
  //       cout << i << "," << j << endl;
      }
      cout<<endl;
      
   }
}

void clean(int n, int s)
{
   for(int i = 0; i < HEIGHT(s); i++)
      for(int j = 0; j < WIDTH(n, s); j++)
         digits[i][j] = ' ';
}

void drawHorizontalLine(int posy, int posx, int s)
{
   int x = WIDTH(posx,s) + (posx>0?1:0) + 1;
   int y = posy;
   for(int i = 0; i < s; i++)
   {
      digits[y][x++] = '-';
      ///cout << y << " " << x << endl;
   }
}

void drawTopLine(int pos, int s)
{
   drawHorizontalLine(0, pos, s);
}

void drawMiddleLine(int pos, int s)
{
   drawHorizontalLine((int)(HEIGHT(s)/2), pos, s);
}

void drawBottomLine(int pos, int s)
{
   drawHorizontalLine(HEIGHT(s)-1, pos, s);
}

void drawVerticalLine(int linenumber, int pos, int s)
{
   int x = WIDTH(pos,s) + (linenumber>1? (pos>0 ? s+2 : s+1) : (pos>0 ? 1 : 0));;
   int y = (linenumber==0 || linenumber ==2 ? 1 : (int)(HEIGHT(s)/2) + 1);
   for(int i = 0; i < s; i++)
   {
      digits[y++][x] = '|';
      ///cout << y << " " << x << endl;
   }
}

int main()
{
   int s, lenn;
   string n;
   while(true)
   {
      cin>>s;
      cin>>n;
      
      if(s == 0) break;
      
      lenn = n.size();
      
      clean(lenn, s);
      
      for(int i = 0; i < lenn; i++)
      {
         if (n[i] == '1')
         {               
            drawVerticalLine(2,i,s);
            drawVerticalLine(3,i,s);
         } else if(n[i] == '2')
         {               
            drawVerticalLine(1,i,s);
            drawVerticalLine(2,i,s);
            drawTopLine(i, s);
            drawMiddleLine(i, s);
            drawBottomLine(i, s);
         } else if(n[i] == '3')
         {               
            drawVerticalLine(2,i,s);
            drawVerticalLine(3,i,s);
            drawTopLine(i, s);
            drawMiddleLine(i, s);
            drawBottomLine(i, s);
         } else if(n[i] == '4')
         {               
            drawVerticalLine(0,i,s);
            drawVerticalLine(2,i,s);
            drawVerticalLine(3,i,s);
            drawMiddleLine(i, s);
         } else if(n[i] == '5')
         {               
            drawVerticalLine(0,i,s);
            drawVerticalLine(3,i,s);
            drawTopLine(i, s);
            drawMiddleLine(i, s);
            drawBottomLine(i, s);
         } else if(n[i] == '6')
         {               
            drawVerticalLine(0,i,s);
            drawVerticalLine(1,i,s);
            drawVerticalLine(3,i,s);
            drawTopLine(i, s);
            drawMiddleLine(i, s);
            drawBottomLine(i, s);
         } else if(n[i] == '7')
         {               
            drawVerticalLine(2,i,s);
            drawVerticalLine(3,i,s);
            drawTopLine(i, s);
         } else if(n[i] == '8')
         {               
            drawVerticalLine(0,i,s);
            drawVerticalLine(1,i,s);
            drawVerticalLine(2,i,s);
            drawVerticalLine(3,i,s);
            drawTopLine(i, s);
            drawMiddleLine(i, s);
            drawBottomLine(i, s);
         } else if(n[i] == '9')
         {
            drawVerticalLine(0,i,s);
            drawVerticalLine(2,i,s);
            drawVerticalLine(3,i,s);
            drawTopLine(i, s);
            drawMiddleLine(i, s);
            drawBottomLine(i, s);
         } else
         {
            drawVerticalLine(0,i,s);
            drawVerticalLine(1,i,s);
            drawVerticalLine(2,i,s);
            drawVerticalLine(3,i,s);
            drawTopLine(i, s);
            drawBottomLine(i, s);
         }
         
      }
      print(lenn, s);
      cout<<endl;    
   }
   return 0;
}
